
import java.awt.Color;
import java.awt.event.MouseWheelEvent;
import java.awt.event.MouseWheelListener;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

import processing.core.*;


public class MainView extends PApplet implements MouseWheelListener {
	private PImage logo; // Logo of RetailM
	private int width = 1500;
	private int height = 750;
	private Integrator openingScreen;
	public int view = 0;
	private Timer firstView;
	private CircleDynamicButton layout, product, print, close,back;
	 View mainView;
	private String mainScreenButtonText;
	private int mainScreenMessagePosX, mainScreenMessagePosY;
	private ArrayList<CircleDynamicButton> mainScreenButtons;
	private IconsView iconsView;
	private MapView mapView;
	private ProductView productView;
	private CheckoutView checkoutView;
	private SearchView searchView;
	private RectangularButton newProductButton, deleteProductButton, editProductButton, saveLayoutButton, clearLayoutButton;
	private boolean dragging,draggingShape;
	private Product dragged;
	private Shape draggedShape;
	// For Testing purposes. Remove when done
		ArrayList<Product> productsList;
	
	public void setup() {
		size(1500,700);
		background(0);
		addMouseWheelListener(this);
		// Setting Up Images used

		logo = loadImage("logo.png");
		logo.resize(1500,0);

		// Setting Up Integrators
		openingScreen = new Integrator(255);
		openingScreen.target(0);
		openingScreen.attraction = 0.05f;

		firstView = new Timer(2100);
		firstView.start();

		// Setting Up Main View
		mainView = new View (0,0,width,height,this);
		

		//Setting Up Buttons used
		
		mainScreenButtons = new ArrayList<CircleDynamicButton> ();
		layout = new CircleDynamicButton(100,100, 400, 400, this, "ShopIcon.png", "Edit the Store Layout", 560, 600,2, true);
		mainView.subviews.add(layout);
		mainScreenButtons.add(layout);
		product = new CircleDynamicButton(550,100, 400, 400, this, "ProductIcon.png", "Edit Product Quantities or Information", 390, 600,3,true);
		mainView.subviews.add(product);
		mainScreenButtons.add(product);
		print = new CircleDynamicButton(1000,100, 400, 400, this, "checkout.png", "Checkout",720, 600,4,true);
		mainView.subviews.add(print);
		mainScreenButtons.add(print);
		close = new CircleDynamicButton(90,20, 50, 50, this, "delete.png", "Close",720, 600,1,false);
		back = new CircleDynamicButton(90,20, 50, 50, this, "delete.png", "Back",720, 600,2,false);
		//Setting Up the widgets used in the different views
		
		iconsView = new IconsView(90, 85, 520,70,this);
		mapView = new MapView (90, 160, 1320, 580, this);
        productView = new ProductView(90,160,850,570,this);
        checkoutView = new CheckoutView(130, 70, this);
        searchView = new SearchView(970,100,450,630,this);
        newProductButton = new RectangularButton(90,100,200,50,this,1);
        newProductButton.setCaption("Create a Product");
        newProductButton.setDelegate(productView);
        editProductButton = new RectangularButton(300,100,200,50,this,2);
        editProductButton.setCaption("Edit Product");
        editProductButton.setDelegate(productView);
        deleteProductButton = new RectangularButton(510,100,200,50,this,3);
        deleteProductButton.setCaption("Delete Product");
        deleteProductButton.setDelegate(productView);
        clearLayoutButton = new RectangularButton(1210,100,200,50,this,3);
        clearLayoutButton.setCaption("Clear Layout");
        clearLayoutButton.setDelegate(mapView);
        saveLayoutButton = new RectangularButton(1000,100,200,50,this,3);
        saveLayoutButton.setCaption("Save Layout");
        saveLayoutButton.setDelegate(mapView);
        
        //Products For Testing
        productsList = new ArrayList<Product>();
        productsList.add(new Product(1, "Folgers Coffee", 5, 6, 7, 3, 0, 0));

        productsList.add(new Product(1, "Tea", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Cheese", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Fish", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Meat", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Mayo", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nutella", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nuts", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nuts", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nuts", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nuts", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nuts", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nuts", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nuts", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nuts", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nuts", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nuts", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nuts", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nuts", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nuts", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nuts", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nuts", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nuts", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nuts", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nuts", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nuts", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nuts", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nuts", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nuts", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nuts", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nuts", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nuts", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nuts", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nuts", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nuts", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nuts", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nuts", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nuts", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nuts", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nuts", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nuts", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nuts", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nuts", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nuts", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nuts", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nuts", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nuts", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nuts", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nuts", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nuts", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nuts", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nuts", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nuts", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nuts", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nuts", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nuts", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nuts", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nuts", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nuts", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nuts", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nuts", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nuts", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nuts", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nuts", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nuts", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nuts", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nuts", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nuts", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nuts", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nuts", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nuts", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nuts", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nuts", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nuts", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nuts", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nuts", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nuts", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nuts", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nuts", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nuts", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nuts", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nuts", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nuts", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nuts", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nuts", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nuts", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nuts", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nuts", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nuts", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nuts", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nuts", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nuts", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nuts", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nuts", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nuts", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nuts", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nuts", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nuts", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nuts", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nuts", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nuts", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nuts", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nuts", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nuts", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nuts", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nuts", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nuts", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nuts", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nuts", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nuts", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nuts", 5, 6, 7, 3, 0, 0));
        productsList.add(new Product(1, "Nuts", 5, 6, 7, 3, 0, 0));
        
	
        dragging = false;
        draggingShape = false;
	}


	public void draw() {
		//System.out.println("View  = "+view);
		if(view == 0){
			// Opening Screen
			image(logo, 0 , height/2 - height/4);
			fill(0,openingScreen.value);
			rect(0,0,width, height);
			openingScreen.update();
			fill(230,230,230);
			if(firstView.isFinished()){
				view = 1;

				openingScreen.value = 0;
				openingScreen.target(255);
				openingScreen.attraction = 0.01f;
			}
		}else{
			
			fill(0,191,255,openingScreen.value);
			rect(0,0,width,height);
			mainView.mouseDetected(mouseX, mouseY);
			
			if(view == 1){

				
			
				openingScreen.update();
				if(!layout.isSelected() && !product.isSelected() && !print.isSelected())
					mainScreenButtonText = "";
				else{
					if(!mainScreenButtonText.equals("")){
						int boxWidth = this.mainScreenButtonText.length()* 25;
						int boxHeight = 50;
						int boxX = width/2-boxWidth/2;
						int boxY = this.mainScreenMessagePosY-40;
						
						fill(24,116,205);
						rect( boxX, boxY, boxWidth, boxHeight);
						
						fill(255);
						textSize(40);
						textAlign(PApplet.CENTER, PApplet.TOP);
						text(mainScreenButtonText,boxX+boxWidth/2, boxY);
					}
				}
				
								

				
			}
			
			mainView.draw();
		   if(dragging){
			   
			   stroke(135,206,235);
				strokeWeight(2);
				fill(24,116,205);
				rect(mouseX,mouseY,450,30);
				fill(255);

			    textAlign(LEFT, BASELINE);
			    textSize(16);
			    //parent
			    String name = dragged.getProductName();
			    if(name.length() > 40 ){
			    	name = name.substring(0, 40);
			    	name += "...";
			    }
				text(name,mouseX+15, mouseY+20);
		   }
		   if(draggingShape){
			   if(draggedShape.type==1){
				   strokeWeight(4);
				   stroke(176,23,31);
				   fill(255);
				   rect(mouseX,mouseY,draggedShape.w,draggedShape.h);
				   noStroke();
			   }
			   if(draggedShape.type == 2){
				   strokeWeight(4);
				   stroke(67,110,238);
				   fill(255);
				   ellipse(mouseX,mouseY,draggedShape.w,draggedShape.h);
				   noStroke(); 
			   }
		   }
			
		}
		if(view == 3){
			if(!mainScreenButtonText.equals("")){
			fill(24,116,205);
			rect(this.mainScreenMessagePosX-10, this.mainScreenMessagePosY-40,this.mainScreenButtonText.length()* 20 + 10, 50);
			
			fill(255);
			textSize(40);
			textAlign(this.LEFT, this.BASELINE);
			text(mainScreenButtonText,this.mainScreenMessagePosX, this.mainScreenMessagePosY);
		}
		}

	}
	public void keyPressed(){
		
		mainView.keyPressed(key);
		
	}
	public void changeView(){
		//System.out.println("Changing View to view "+view);
		if(view == 1){
			
		
			if(!mainView.subviews.contains(layout))mainView.subviews.add(layout);
			
			if(!mainView.subviews.contains(product))mainView.subviews.add(product);
			
			if(!mainView.subviews.contains(print))mainView.subviews.add(print);
			
			if(mainView.subviews.contains(close))mainView.subviews.remove(close);
			
			if(mainView.subviews.contains(iconsView))mainView.subviews.remove(iconsView);
			
			if(mainView.subviews.contains(mapView))mainView.subviews.remove(mapView);
			
			if(mainView.subviews.contains(productView))mainView.subviews.remove(productView);
			
			if(mainView.subviews.contains(searchView))mainView.subviews.remove(searchView);
			
			if(mainView.subviews.contains(newProductButton))mainView.subviews.remove(newProductButton);
			
			if(mainView.subviews.contains(editProductButton))mainView.subviews.remove(editProductButton);
			
			if(mainView.subviews.contains(deleteProductButton))mainView.subviews.remove(deleteProductButton);
			
			if(mainView.subviews.contains(checkoutView))mainView.subviews.remove(checkoutView);
			
			if(mainView.subviews.contains(clearLayoutButton))mainView.subviews.remove(clearLayoutButton);
			
			if(mainView.subviews.contains(saveLayoutButton))mainView.subviews.remove(saveLayoutButton);
		}
		if(view == 2){ // Store layout
			this.mainScreenButtonText = "";
            if(mainView.subviews.contains(layout))mainView.subviews.remove(layout);
			
            if(mainView.subviews.contains(product))mainView.subviews.remove(product);
			
            if(mainView.subviews.contains(print))mainView.subviews.remove(print);
		
            if(!mainView.subviews.contains(close))mainView.subviews.add(close);
            
            if(!mainView.subviews.contains(iconsView))mainView.subviews.add(iconsView);
            
            if(!mainView.subviews.contains(mapView))mainView.subviews.add(mapView);
            
            if(!mainView.subviews.contains(clearLayoutButton))mainView.subviews.add(clearLayoutButton);
			
			if(!mainView.subviews.contains(saveLayoutButton))mainView.subviews.add(saveLayoutButton);	
			
			 if(mainView.subviews.contains(back))mainView.subviews.remove(back);
		}
		if(view == 3){ // Product view
			this.mainScreenButtonText = "";
			
			    if(mainView.subviews.contains(layout))mainView.subviews.remove(layout);
				
	            if(mainView.subviews.contains(product))mainView.subviews.remove(product);
				
	            if(mainView.subviews.contains(print))mainView.subviews.remove(print);
				
	            if(!mainView.subviews.contains(close))mainView.subviews.add(close);
	            
	            if(!mainView.subviews.contains(productView))mainView.subviews.add(productView);
	            
	            if(!mainView.subviews.contains(searchView))mainView.subviews.add(searchView);
	            
	            if(!mainView.subviews.contains(newProductButton))mainView.subviews.add(newProductButton);
	            
	            if(!mainView.subviews.contains(editProductButton))mainView.subviews.add(editProductButton);
	            
	            if(!mainView.subviews.contains(deleteProductButton))mainView.subviews.add(deleteProductButton);
		}
		if(view == 4){ // Print
		
			this.mainScreenButtonText = "";
			
			 if(mainView.subviews.contains(layout))mainView.subviews.remove(layout);
				
	         if(mainView.subviews.contains(product))mainView.subviews.remove(product);
				
	         if(mainView.subviews.contains(print))mainView.subviews.remove(print);
	         
	         if(!mainView.subviews.contains(close))mainView.subviews.add(close);
	         
	         if(!mainView.subviews.contains(checkoutView))mainView.subviews.add(checkoutView);
		}
		
		if(view == 5){
			    if(mainView.subviews.contains(close))mainView.subviews.remove(close);

			    if(!mainView.subviews.contains(back))mainView.subviews.add(back);
	            
	            if(mainView.subviews.contains(iconsView))mainView.subviews.remove(iconsView);
	            
	            if(mainView.subviews.contains(mapView))mainView.subviews.remove(mapView);
	            
	            if(mainView.subviews.contains(clearLayoutButton))mainView.subviews.remove(clearLayoutButton);
				
				if(mainView.subviews.contains(saveLayoutButton))mainView.subviews.remove(saveLayoutButton);	
		}
	}
	public void mousePressed(){
		
		mainView.mousePressed(mouseX, mouseY);
	}
    public void mouseDragged(){
		
		mainView.mouseDragged(mouseX, mouseY);

		
    }
    public void mouseReleased(){
		
		mainView.mouseReleased(mouseX, mouseY);
		dragged = null;
		dragging = false;
		draggingShape = false;
		draggedShape = null;
		
    }
    
	public static void main(String args[]) {
		
		PApplet.main(new String[] { "--present", "MainView" });
		
		DBConnection userCon = new DBConnection(Constants.DBType.EUSERS);
		userCon.connect();
		
		DBConnection prodCon = new DBConnection(Constants.DBType.EPRODUCTS);
		prodCon.connect();
		
		/*
		//testing insertRecord
		User user = new User("testname", "testpass", 2);
		//userCon.insertRecord( user ); //works
		//user.setLogin("Joseph");
		//userCon.updateRecord(user); //works
		
		Product sp1 = new Product(1, "Prod1", 5, 6, 7, 3, 0, 0);
		prodCon.insertRecord( sp1 ); //works
		//sp1.setProductName("Prod_1");
		//prodCon.updateRecord(sp1); //works
		
		Product sp2 = new Product(1, "Prod2", 6, 6, 7, 3, 0, 0);
		prodCon.insertRecord( sp2 ); //works
		sp2.setProductName("Prod_2");
		prodCon.updateRecord(sp2); //works
		
		Product sp3 = new Product(1, "Prod3", 6, 6, 7, 3, 0, 0);
		prodCon.insertRecord( sp3 ); //works
		sp3.setProductName("Prod_3");
		prodCon.updateRecord(sp3); //works
		
		Product sp4 = new Product(1, "Prod4", 5, 6, 7, 3, 0, 0);
		prodCon.insertRecord( sp4 ); //works
		sp4.setProductName("Prod_4");
		prodCon.updateRecord(sp4); //works
		
		
		//next, test getRecord(s)
		Map<String, String> m = new HashMap<String, String>();
		m.put("productHeight", "6");
		Record results[] = prodCon.getRecords( m );
		
		for(int i = 0; i < results.length; i++)
		{
			System.out.println("Got product: " + ((Product)(results[i])).getProductName() + 
					", " + ((Product)(results[i])).getHeight());
		}
		
		*/
		
		/** Procedure for getting products from database:
		 * 
		 * Connect to the database
		 * 
		 * DBConnection prodCon = new DBConnection(Constants.DBType.EPRODUCTS);
		 * prodCon.connect();
		 * 
		 * Put your search terms in a Map, where the attribute is the key and value is the value, like:
		 * Map<String, String> m = new HashMap<String, String>();
		 * m.put("productHeight", "6");
		 * 
		 * Get results like this:
		 * Record results[] = prodCon.getRecords( m );
		 */
		
		
		
		
	}

	public void setMainScreenMessage(String s, int x, int y){
		this.mainScreenButtonText = s;
		this.mainScreenMessagePosX = x;
		this.mainScreenMessagePosY = y;
	}
	
	public void setElseFalse(CircleDynamicButton b){
		
		for(int i = 0; i < mainScreenButtons.size(); i++){
	
			CircleDynamicButton tmp = mainScreenButtons.get(i);
			if(!tmp.equals(b))
				tmp.setSelected(false);
		}
		
	}
	public Product getDragged(){
		return this.dragged;
	}
	public Shape getDraggedShape(){
		return this.draggedShape;
	}
	public void setDragged(Product p){
		this.dragged = p;
	}
	public void setDraggedShape(Shape s){
		this.draggedShape = s;
	}
	public boolean getDragging(){
		return this.dragging;
	}
	public void setDragging(boolean dragging){
		this.dragging = dragging;
	}
	public boolean getDraggingShape(){
		return this.draggingShape;
	}
	public void setDraggingShape(boolean dragging){
		this.draggingShape = dragging;
	}
	
	public void addSearchView(){
		mainView.subviews.add(searchView);
	}
	public void removeSearchView(){
		mainView.subviews.remove(searchView);
	}



	public void mouseWheelMoved(MouseWheelEvent e) {
		mainView.mouseWheel(e.getX(), e.getY(), e.getUnitsToScroll());
	}

}


